var httpRequest = null;

var ConnectionTypes = [
  function() { return new XMLHttpRequest() },
  function() { return new ActiveXObject('Microsoft.XMLHTTP') },
  function() { return new ActiveXObject('Msxml2.XMLHTTP') }
];
for ( i = 0 ; i < ConnectionTypes.length ; ++i ) {
  try {
    httpRequest = ConnectionTypes[ i ]();
    break;
  } catch ( e ) {}
}